home *** CD-ROM | disk | FTP | other *** search
- // GETINFO SCRIPTING
- // Carteles-Metropoli v1.0 by micmic.ifs
-
- (***************************************************
- * Author: micmic (micmic@dieznet.com) *
- * Script for the importation of pictures from *
- * carteles.metropoliglobal.com *
- * *
- * For use with Ant Movie Catalog 3.4.0 *
- * www.ant.be.tf/moviecatalog ╖╖╖ www.buypin.com *
- * *
- * The source code of the script can be used in *
- * another program only if full credits to *
- * script author and a link to Ant Movie Catalog *
- * website are given in the About box or in *
- * the documentation of the program *
- ***************************************************)
-
- program micmic;
- var
- MovieName: string;
- const
- Base = 'http://carteles.metropoliglobal.com/';
- BaseURL = 'http://carteles.metropoliglobal.com/4resultados.php?titulo=';
- BaseURL2 = '&director=&interpretes=&Submit=Buscar';
-
- function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
- var
- i: Integer;
- begin
- result := -1;
- if StartAt < 0 then
- StartAt := 0;
- for i := StartAt to List.Count-1 do
- if Pos(Pattern, List.GetString(i)) <> 0 then
- begin
- result := i;
- Break;
- end;
- end;
-
- procedure AnalyzePage(Address: string);
- var
- Page: TStringList;
- LineNr: Integer;
- PosIni, PosFin: Integer;
- Line, SubLine: string;
- Title, DirURL: string;
- txtTemp: string;
- begin
- Page := TStringList.Create;
- Page.Text := GetPage(Address);
- if Pos('No se han encontrado resultados', Page.Text) > 0 then
- begin
- ShowMessage('No se ha encontrado ning·n artφculo por tφtulo.');
- end else
- begin
- PickTreeClear;
- PickTreeAdd('Resultados de la b·squeda para "' + MovieName + '":', '');
-
- // buscamos los resultados
- LineNr := 0;
-
- while LineNr < Page.Count do
- begin
- SubLine := Page.GetString(LineNr);
- txtTemp := '<td width="92%"><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="';
- PosIni := pos(txtTemp, SubLine);
- if PosIni > 0 then
- begin
- SubLine := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
-
- txtTemp := '">';
- PosFin := pos(txtTemp, SubLine);
- DirURL := Base + Copy(SubLine, 1, PosFin - 1);
-
- SubLine := Copy(SubLine, PosFin + Length(txtTemp), Length(SubLine));
- txtTemp := '</a>';
- PosFin := pos(txtTemp, SubLine);
- Title := Copy(SubLine, 1, PosFin - 1);
-
- //ShowMessage(Title + '-->' + DirURL);
- PickTreeAdd(Title, DirURL);
- end;
- LineNr := LineNr + 1;
- end;
-
- Page.Free;
- if PickTreeExec(Address) then
- AnalyzeMoviePage(Address);
- end;
- end;
-
-
- procedure AnalyzeMoviePage(Address: string);
- var
- Page: TStringList;
- PosIni, PosFin: Integer;
- dirBase: string;
- txtTemp: string;
- txtAux: string;
- campo, valor: string;
- LineNr: Integer;
- Line, SubLine: string;
- Imagen: string;
- Comentarios: string;
- begin
- //ShowMessage(Address);
-
- SetField(fieldURL, Address);
-
- Page := TStringList.Create;
- Page.Text := StringReplace(GetPage(Address), '<br>', #13#10);
-
- // buscamos los campos
- Comentarios := '';
- Imagen := '';
- LineNr := 0;
- while LineNr < Page.Count do
- begin
- SubLine := Page.GetString(LineNr);
-
- txtTemp := '<title>';
- PosIni := pos(txtTemp, SubLine);
- if PosIni > 0 then
- begin
- txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
- PosFin := pos('</title>', txtAux);
- campo := Copy(txtAux, 1, PosFin - 1);
- if campo <> '' then SetField(fieldTranslatedTitle, campo);
- end;
-
- txtTemp := '<td width="68%" valign="TOP" bgcolor="#F5F5F5"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">';
- PosIni := pos(txtTemp, SubLine);
- if PosIni > 0 then
- begin
- txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
- PosFin := pos('</font></td>', txtAux);
- campo := Copy(txtAux, 1, PosFin - 1);
- if campo <> '' then SetField(fieldOriginalTitle, campo);
- end;
-
- txtTemp := '<td valign="TOP" bgcolor="#FFFFFF"><div align="right"><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">';
- PosIni := pos(txtTemp, SubLine);
- if PosIni > 0 then
- begin
- txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
- PosFin := pos(':', txtAux);
- campo := Copy(txtAux, 1, PosFin - 1);
-
- LineNr := LineNr + 2;
- SubLine := Page.GetString(LineNr);
- txtTemp := '<td valign="TOP" bgcolor="#F5F5F5"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">';
- PosIni := pos(txtTemp, SubLine);
- txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
- PosFin := pos('</font></td>', txtAux);
- valor := Copy(txtAux, 1, PosFin - 1);
-
- if campo = 'AÑO' then SetField(fieldYear, valor);
- if campo = 'NACIONALIDAD' then SetField(fieldCountry, valor);
- if campo = 'DIRECTOR' then SetField(fieldDirector, valor);
- if campo = 'INTÉRPRETES' then SetField(fieldActors, valor);
-
- if campo = 'DURACION' then Comentarios := Comentarios + 'Duraci≤n: ' + valor + #13#10;
- if campo = 'GUIÓN' then Comentarios := Comentarios + 'Gui≤n: ' + valor + #13#10;
- if campo = 'FOTOGRAFÍA' then Comentarios := Comentarios + 'Fotografφa: ' + valor + #13#10;
- if campo = 'MÚSICA' then Comentarios := Comentarios + 'M·sica: ' + valor + #13#10;
-
- //ShowMessage(campo + '-->' + valor);
- end;
-
- txtTemp := '/cpp/albums/userpics/';
- PosIni := pos(txtTemp, SubLine);
- if PosIni > 0 then
- begin
- txtAux := Copy(SubLine, PosIni, Length(SubLine));
- PosFin := pos('" width="', txtAux);
- campo := Copy(txtAux, 1, PosFin - 1);
- if Imagen = '' then Imagen := Base + campo;
- end;
- //this is the other directory I found
- txtTemp := '/c/';
- PosIni := pos(txtTemp, SubLine);
- if ((PosIni > 0) and (Imagen = '')) then
- begin
- txtAux := Copy(SubLine, PosIni, Length(SubLine));
- PosFin := pos('" width="', txtAux);
- campo := Copy(txtAux, 1, PosFin - 1);
- if Imagen = '' then Imagen := Base + campo;
- end;
-
- txtTemp := '<td valign="TOP" colspan="2"><font size="1" face="Arial, Helvetica, sans-serif">';
- PosIni := pos(txtTemp, SubLine);
- if PosIni > 0 then
- begin
- txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
- PosFin := pos('</font></td>', txtAux);
- campo := Copy(txtAux, 1, PosFin - 1);
- if campo <> '' then SetField(fieldDescription, campo);
- end;
-
- LineNr := LineNr + 1;
- end;
-
- if Comentarios <> '' then SetField(fieldComments, Comentarios);
- if Imagen <> '' then GetPicture(Imagen, False);
-
- Page.Free;
- DisplayResults;
- end;
-
- // bmicmic: Bucle Principal
- begin
- if CheckVersion(3,4,0) then
- begin
- MovieName := GetField(fieldOriginalTitle);
- if MovieName = '' then
- MovieName := GetField(fieldTranslatedTitle);
- Input('Importar de Carteles.Metropoli', 'Introduce el Titulo de la Pelicula:', MovieName);
- AnalyzePage(BaseURL + UrlEncode(MovieName) + BaseURL2);
-
- end else
- ShowMessage('Este script necesita una versi≤n superior de Ant Movie Catalog (al menos la version 3.4.0)');
- end.
-